﻿using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using BOL;

namespace DAL
{
    public class UrlDb
    {
        private readonly UrlManagementEntities _db;

        public UrlDb()
        {
            _db = new UrlManagementEntities();
        }

        public IEnumerable<tbl_Url> GetAll()
        {
            return _db.tbl_Url.ToList();
        }

        public tbl_Url GetById(int id)
        {
            return _db.tbl_Url.Find(id);
        }
        public void Insert(tbl_Url url)
        {
            _db.tbl_Url.Add(url);
        }

        public void Update(tbl_Url url)
        {
            _db.Entry(url).State = EntityState.Modified;
            _db.SaveChanges();
        }

        public void Delete(int id)
        {
            var url = _db.tbl_Url.Find(id);
            _db.tbl_Url.Remove(url);
            _db.SaveChanges();
        }

       
    }
}
